package com.jzo2o.customer.controller.consumer;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jzo2o.common.model.PageResult;
import com.jzo2o.customer.model.domain.AddressBook;
import com.jzo2o.customer.model.dto.request.AddressBookPageQueryReqDTO;
import com.jzo2o.customer.model.dto.request.AddressBookUpsertReqDTO;
import com.jzo2o.customer.model.dto.request.EvaluationPageByTargetReqDTO;
import com.jzo2o.customer.model.dto.response.EvaluationResDTO;
import com.jzo2o.customer.service.IAddressBookService;
import com.jzo2o.mysql.utils.PageUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("consumerAddressController")
@RequestMapping("/consumer")
@Api(tags = "用户端 - 地址相关接口")
public class ConsumerAddressController {

    @Autowired
    IAddressBookService addressBookService;

    @PostMapping("/address-book")
    @ApiOperation("新增地址簿")
    public void addAddressBook(@RequestBody AddressBookUpsertReqDTO reqData) {
         addressBookService.addAddressBook(reqData);
    }

    @GetMapping("/address-book/page")
    @ApiOperation("分页查询地址簿")
    public PageResult<AddressBook> pageSelect(AddressBookPageQueryReqDTO reqDTO) {
       return addressBookService.pageSelect(reqDTO);
    }

    @GetMapping("/address-book/{id}")
    @ApiOperation("根据id查询地址")
    public AddressBook getById(@PathVariable("id") Long id) {
        return addressBookService.getById(id);
    }

    @PutMapping("/address-book/{id}")
    @ApiOperation("根据id查询地址")
    public void addressBookUpdateById(@PathVariable Long id, @RequestBody AddressBookUpsertReqDTO reqDTO) {
         addressBookService.addressBookUpdateById(id,reqDTO);
    }

    @DeleteMapping("/address-book/batch")
    @ApiOperation("批量删除地址")
    public void batchDelete(@RequestBody List<Long> ids) {
        addressBookService.batchDelete(ids);
    }
}
